package com.ncloud.product.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.ncloud.product.entity.ChnlDiscount;

@Mapper
public interface ChnlDiscountMapper {

	@Select("select * from bs_p_chnl_discount where chnl_id = #{chnlId} and object_type=#{objectType}"
			+ " and object_id = #{objectId} and now() between begin_date and end_date")
	@Results({@Result(column="discount_id",property="discountId"), @Result(column="price_id",property="priceId"),
		@Result(column="chnl_id",property="chnlId"), @Result(column="post_level",property="postLevel"),
		@Result(column="object_type",property="objectType"), @Result(column="object_id",property="objectId"),
		@Result(column="discount",property="discount"), @Result(column="state",property="state"),
		@Result(column="create_date",property="createDate"), @Result(column="create_user",property="createUser"),
		@Result(column="update_date",property="updateDate"), @Result(column="update_user",property="updateUser"),
		@Result(column="remark",property="remark"),@Result(column="price",property="price"),
		@Result(column="discount_type",property="discountType")})
	ChnlDiscount getDiscountByChnlId(@Param("chnlId")Long chnlId,
			@Param("objectType")String objectType, @Param("objectId")Long objectId);


	@Select("select * from bs_p_chnl_discount where chnl_id = #{chnlId} "
			+ " and object_id = #{objectId} and now() between begin_date and end_date")
	@Results({@Result(column="discount_id",property="discountId"), @Result(column="price_id",property="priceId"),
			@Result(column="chnl_id",property="chnlId"), @Result(column="post_level",property="postLevel"),
			@Result(column="object_type",property="objectType"), @Result(column="object_id",property="objectId"),
			@Result(column="discount",property="discount"), @Result(column="state",property="state"),
			@Result(column="create_date",property="createDate"), @Result(column="create_user",property="createUser"),
			@Result(column="update_date",property="updateDate"), @Result(column="update_user",property="updateUser"),
			@Result(column="remark",property="remark"),@Result(column="price",property="price"),
			@Result(column="discount_type",property="discountType")})
	ChnlDiscount getDiscountNotBase(@Param("chnlId")Long chnlId, @Param("objectId")Long objectId);
}
